import axios from "../util/axios";

// 新增地址
export function addAddress(params) {
  return axios.post("/address", params, {
    headers: {
      token: localStorage.getItem("token") || "",
    },
  });
}

// 编辑地址
export function EditAddress(params) {
  return axios.put("/address", params, {
    headers: {
      token: localStorage.getItem("token") || "",
    },
  });
}

// 删除地址
export function DeleteAddress(id) {
  return axios.delete(`/address/${id}`, {
    headers: {
      token: localStorage.getItem("token") || "",
    },
  });
}

export function getDefaultAddress() {
  return axios.get("/address/default", {
    headers: {
      token: localStorage.getItem("token") || "",
    },
  });
}

export function getAddressList() {
  return axios.get("/address", {
    params: { pageNumber: 1, pageSize: 1000 },
    headers: {
      token: localStorage.getItem("token") || "",
    },
  });
}

export function getAddressDetail(id) {
  return axios.get(`/address/${id}`, {
    headers: {
      token: localStorage.getItem("token") || "",
    },
  });
}
